<?php
class myPdo extends PDO
{
	public function __construct($dsn, $user=NULL, $password=NULL)
    {
        parent::__construct($dsn, $user, $password);
        $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        //$this->exec("SET NAMES 'utf8'");
    }

    public function prepare($sql, $options=NULL)
    {
        $statement = parent::prepare($sql);
        if(strpos(strtoupper($sql), 'SELECT') === 0 || strpos(strtoupper($sql), 'SHOW') === 0 || strpos(strtoupper($sql), 'DESCRIBE') === 0) //requ�te "SELECT" "SHOW" "DESCRIBE"
        {
            $statement->setFetchMode(PDO::FETCH_ASSOC);
        }

        return $statement;
    }
}

